home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
gfx
/
fract
/
FlashMandel.lha
/
FlashMandel
/
Sources
/
Modules
/
MandReal.P
< prev
next >
Wrap
Text File
|
1999-01-22
|
4KB
|
88 lines
************************************************************************
** Written by Dino Papararo 09-Nov-1998
**
** FUNCTION
**
** MandReal -- perform Z = Z^2 + C iteration.
**
** SYNOPSIS
**
** WORD MandFPU (WORD Iterations,long double Cre,long double Cim)
**
**
** DESCRIPTION
**
** C equivalent function:
**
** ***************************************************************
** *WORD Real (WORD Iterazioni,long double Cre,long double Cim)***
** *{ ***
** *register long double zr,zi,zi2,Dist,MaxDist; ***
** * ***
** * zi = Cim; ***
** * ***
** * zr = Cre; ***
** * ***
** * MaxDist = 4.0; ***
** * ***
** * do { ***
** * zi2 = zi * zi; ***
** * ***
** * zi = zr + zr; ***
** * ***
** * Dist = zr * zr + zi2; ***
** * ***
** * zr = zr * zr - zi2; ***
** * ***
** * zi = zi * zi + Cim; ***
** * ***
** * zr = zr + Cre; ***
** * ***
** * } while (-- Iterazioni && (MaxDist > Dist)); ***
** * ***
** * if (Iterazioni <= 0) Iterazioni = 1; ***
** * ***
** * return Iterazioni; ***
** *} ***
** ***************************************************************
**
** This function tests if a point belongs or not at mandelbrot's set
**
** Optimized for pipelines of PPC coprocessors
**
** NOTICE: ALL VARIABLES ARE INTO REGISTERS FOR FULL SPEEEED
**
** r3:Iterations
** f0:Cre f1:Cim f2:Zr f3:Zi f4:Zi2 f5:Dist f6:MaxDist
XDEF _MandPPC
_MandPPC:
prolog ; start
fmr f3,f1 ; zi = cim
fmr f2,f0 ; zr = cre
ls f7,Four ; maxdist = 4.0
mtctr r3 ; load reg counter with iterations
.Loop
fmul f4,f3,f3 ; zi2 = zi * zi
fadd f3,f2,f2 ; zi = 2 * zr
fmadd f5,f2,f2,f4 ; dist = zr * zr + zi2
fmsub f2,f2,f2,f4 ; zr [new] = zr * zr - zi2
fmadd f3,f3,f3,f1 ; zi = zi * zi + Cim
fadd f2,f2,f0 ; zr [new] = zr + Cre
fcmpu f5,f6 ; if maxdist > dist and
bdnzf GT,.Loop ; if iterations != 0 loop
.Exit
mfctr r3 ; store iterations from reg counter
ble .Jump ; if iterations <= 0
li r3,1 ; Iterations = 1
.Jump
epilog ; end
Four: dc.s 4.0